<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\ordersVpsTarifs;


Class OrdersVpsTarifModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public function findAll()
    {
        $tarifs = $this->em->getRepository('BillingBundle:ordersVpsTarifs')->findAll();
        return $tarifs;
    }
    
    public function findByPK($tarif_id)
    {
        $tarif = $this->em->find('BillingBundle:ordersVpsTarifs', $tarif_id);
        return $tarif;
    }

    public function create($oEntity)
    {
        $this->em->persist($oEntity);
        $this->em->flush();
    }

    public function removeByPK($tarif_id)
    {
        $tarif = $this->em->find('BillingBundle:ordersVpsTarifs', $tarif_id);
        $this->em->remove($tarif);
        $this->em->flush();
    }

    public function checkOrders($tarif_id)
    {
        $order = $this->em->getRepository('BillingBundle:ordersVps')->findOneBy(array('vps_tarif' => $tarif_id));
        if (isset($order))
            return true;
        else
            return false;
    }
}
?>
